DECLARE
	@version_id					INT, 
	@month_period_version_id	INT
/*
SET @version_id = 1
USE CIMaPlanning_qa
*/
USE CIMaPlanning
SET @version_id					= 74
SET @month_period_version_id	= 782

/*
	Distribucion de maiz en plantas
(OLD)
*/

SELECT *
	FROM plants_versions
	ORDER BY month_period_version_id, priority DESC

SELECT pov.is_transit, pov.transit_date, 
		pov.biweek_period_version_id, t.priority transport_priority, 
		dbo.fn_po_code(pov.code, pov.code_number) po_code
	FROM vw_v_purchases_orders_versions pov
		LEFT OUTER JOIN transports t
			ON pov.transport_id = t.transport_id
	WHERE pov.version_id = @version_id
	ORDER BY pov.is_transit DESC, pov.transit_date, 
		pov.biweek_period_version_id, t.priority DESC, 
		dbo.fn_po_code(pov.code, pov.code_number)



return 

SELECT *
	FROM grinds_distributions_priorities_versions

SELECT *
	FROM vw_v_purchases_orders_versions
		